package com.chentf.nio.c3;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;

/**
 * @author chentengfei
 * @desc 多路复用select客户端
 * @date 2022-05-07 20:37:03
 */
public class SelectClient04 {
    public static void main(String[] args) {
        try (SocketChannel sc = SocketChannel.open()){
            sc.connect(new InetSocketAddress("localhost", 8080));
            SocketAddress address = sc.getLocalAddress();
            // sc.write(Charset.defaultCharset().encode("hello\nworld\n"));
            sc.write(Charset.defaultCharset().encode("0123\n456789abcdef"));
            sc.write(Charset.defaultCharset().encode("0123456789abcdef3333\n"));
            System.in.read();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
